<?php

namespace App\Listeners;

use App\Models\Parking;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;

/**
 * 初始化用户的停车位
 * Class SystemParkingListener
 * @package App\Listeners
 */
class SystemParkingListener
{
    /**
     * Create the event listener.
     *
     * @return void
     */
    public function __construct()
    {
        //
    }

    /**
     * Handle the event.
     *
     * @param  object  $event
     * @return void
     */
    public function handle($event)
    {
        $user = $event->user;
        //车位分布情况，1免费车位，2收费车位
        $type_distributes = [1,1,2,2];
    
        foreach ($type_distributes as $type) {
            Parking::create([
                'user_id'=>$user->id,
                'type'=>$type
            ]);
        }
        
        
        
    }
}
